﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ProductComments.aspx.cs"
    Inherits="Maticsoft.Web.wap.ProductComments" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <!--#include file="include/head.htm"-->
    <script type="text/javascript">
        $(function () {
            GetShopCar();
            LoadList();
        })

        function GetShopCar() {
            $.ajax({
                type: "get",
                url: "ProductDetail.aspx",
                data: "ope=carnum&d=" + new Date().toString(),
                success: function (msg) {
                    if (msg != "") {
                        $("#carNum").text(msg);
                    }
                },
                error: function (msg) {

                }
            })
        }

        function LoadList() {
            $.ajax({
                type: "get",
                url: "ProductComments.aspx",
                data: "sync=true&id=" + $("#hidProductId").val() + "&page=" + $("#hidPage").val() + "&d=" + new Date().toString(),
                success: function (msg) {
                    if (msg != "") {
                        var obj = eval('(' + msg + ')');
                        var res = "";
                        $("#commtitle").append("(" + obj.total + ")");
                        for (var i = 0; i < obj.list.length; i++) {
                            res += "<ul class=\"mui-table-view mar-btm-10\">";
                            res += "<li class=\"mui-table-view-cell pad-5-10\"><h5 class=\"tc-black mui-pull-left\" style=\"line-height: 25px;\">" + obj.list[i].nickname + "</h5>";
                            res += "<h6 class=\"tc-lgray mui-pull-right\" style=\"line-height: 25px;\">" + obj.list[i].date + "</h6>";
                            res += "</li>";
                            res += "<li class=\"mui-table-view-cell pad-5-10\"><h5 style=\"padding: 0 0 5px 0; overflow: hidden;\">";
                            for (var j = 0; j < parseInt(obj.point); j++) {
                                res += "<img class=\"mui-pull-left starbox\" src=\"img/xing.png\">";
                            }
                            res += "</h5>";
                            res += "<h5 class=\"tc-black\">" + obj.list[i].detail + "</h5>";
                            res += "</li>";
                            res += "</ul>";
                        }

                        $("#list").prepend(res);

                        if (parseInt(obj.total) > parseInt(obj.currPage)) {
                            $("#hidPage").val(parseInt(obj.currPage) + 1);
                            $("#listMore").show();
                        }
                        else {
                            $("#listMore").hide();
                        }
                    }
                },
                error: function (msg) {

                }
            })
        }

        function LoadMore() {
            LoadList();
        }

        function Buy() {
            window.location.href = "ShoppingCar.aspx?d=" + new Date().toString();
        }

        function AddShoppingCar(op) {
            if ($(".layout").length == 0) {
                alert("请选择规格");
                return;
            }

            $.ajax({
                type: "get",
                url: "ProductDetail.aspx",
                data: "ope=addnum&productId=" + $("#hidProductId").val() + "&num=1&lay=&d=" + new Date().toString(),
                success: function (data) {
                    if (data == "1") {
                        if (op == "1") {
                            Buy();
                            return;
                        }
                        alert("添加成功");
                    }
                    else if (data == "-1") {
                        alert("产品已下架");
                    }
                    else if (data == "-2") {
                        alert("库存不足");
                    }
                    else if (data == "-3") {
                        alert("超出购买限额");
                    }
                    else if (data == "-4") {
                        alert("超出购买限额");
                    }
                    else if (data == "-5") {
                        alert("请先登录");
                    }
                    else {
                        alert("添加失败");
                    }
                },
                error: function () {
                    alert("出错啦");
                }
            })
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:HiddenField ID="hidProductId" runat="server" />
    <asp:HiddenField ID="hidPage" runat="server" />
    <header class="mui-bar">
			<a class="mui-action-back gotoup mui-pull-left"></a>
			<h1 class="mui-title" id="commtitle">商品评价</h1>
			<a class="mui-pull-right tc-black"><img src="img/2_62.png" class="icons-car"><span class="tc-white mui-badge" style="position:absolute;top:2px;right:2px; background-color: #ef0000;" id="carNum"></span></a>
		</header>
    <div class="mui-content pad-btm-60" id="list">
        
        <div id="listMore" style="width: 100%; text-align: center; line-height: 50px; background-color: #f6f4f4;
            cursor: pointer;" onclick="LoadMore();">
            加载更多</div>
        <div class="fix-btm-0">
            <div class="mui-col-xs-6 mui-pull-left">
                <button class="mui-btn-link" type="button" style="border-radius: 0; background-color: #ff9402;" onclick="AddShoppingCar('0');>
                    加入购物车</button>
            </div>
            <div class="mui-col-xs-6 mui-pull-left">
                <button class="mui-btn-link" type="button" style="border-radius: 0;" onclick="AddShoppingCar('1');>
                    立即购买</button>
            </div>
        </div>
    </div>
    </form>
</body>
</html>
